//
//  G9SDKPermissionTool.h
//  NineGameSDK
//
//  Created by hufeng on 2021/7/23.
//  Copyright © 2021 aligames. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "G9GameMacro.h"

NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, EjoyPermissionType) {
    EjoyPermissionTypeNone = 0,
    EjoyPermissionTypePhoto,       ///< 相册
    EjoyPermissionTypeVideo,        ///< 相机
    EjoyPermissionTypeAudio,        ///< 麦克风
    EjoyPermissionTypeLocation,     ///< 地理位置
    EjoyPermissionTypeIDFA,         ///< idfa
//    EjoyPermissionTypeNotification, ///< 推送
//    EjoyPermissionTypeNetwork,      ///< 网络权限
//    EjoyPermissionTypeBluetooth,    ///< 蓝牙
//    EjoyPermissionTypeCanlendar,    ///< 日历
//    EjoyPermissionTypeReminder,     ///< 提醒事项
//    EjoyPermissionTypeContact,      ///< 通讯录
//    EjoyPermissionTypeFaceID,       ///< faceid
//    EjoyPermissionTypeHealth,       ///< 健康系统
//    EjoyPermissionTypeMotion,       ///< 允许访问运动与健康
};

typedef NS_ENUM(NSInteger, EjoyPermissionStatus) {
    EjoyPermissionStatusSuccess = 0, ///< 已获得该权限
    EjoyPermissionStatusFailed = 1, ///< 还没有权限，包括用户未决定
};


@interface G9SDKPermissionTool : NSObject

/**
 *  国内隐私合规的弹窗，APP启动时调用，CP应该在回调里继续后续的流程
 */
+ (void)checkToShowPrivacyProtocolAlertWithType:(G9SDKGameType)gameType completion:(void(^)(void))completion;
+ (void)checkToShowPrivacyProtocolAlertWithType:(G9SDKGameType)gameType rootVC:(UIViewController *)rootVC completion:(void(^)(void))completion;


///< 检查当前APP是否已获取这些权限
+ (EjoyPermissionStatus)checkIfHasPermissionWithType:(EjoyPermissionType)type;

/*
 infoKey可以传入如下字符串
 NSPhotoLibraryUsageDescription
 NSPhotoLibraryAddUsageDescription
 NSCameraUsageDescription
 NSMicrophoneUsageDescription
 NSLocationWhenInUseUsageDescription
 NSLocationAlwaysUsageDescription
 NSLocationAlwaysAndWhenInUseUsageDescription
 NSUserTrackingUsageDescription
*/
+ (EjoyPermissionStatus)checkIfHasPermissionWithInfoStringKey:(NSString *)infoKey;


/*
 * 向系统请求授权，可以在未获得某个权限时调用。
 * 目前type仅支持EjoyPermissionTypePhoto相册、EjoyPermissionTypeAudio麦克风和EjoyPermissionTypeVideo相机这三个权限。
 * 调用接口前，请确保info.plist里添加了对应的权限描述文案，否则APP会crash
 */
+ (void)requestForPermission:(EjoyPermissionType)type completion:(void (^)(BOOL))completion;


/*
 * 跳转到当前APP的设置页面
 */
+ (void)jumpToSettings;

/*
 * iOS使用的每个权限都需要在info.plist里添加对应的key，该接口返回当前游戏APP添加到info.plist里的所有权限描述的key.
 */
+ (NSArray<NSString *> *)getAppAllPermissionStrings;
@end

NS_ASSUME_NONNULL_END
